package com.huawei.appmarket.service.substance;

import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import com.huawei.appgallery.foundation.service.common.protocol.AppListFragmentProtocol;
import com.huawei.appgallery.foundation.store.bean.detail.DetailResponse;
import com.huawei.appgallery.foundation.ui.css.CSSDeclaration;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSSelector;
import com.huawei.appgallery.foundation.ui.css.CSSStyleSheet;
import com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSMonoColor;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.fragment.AppListFragment;
import com.huawei.appgallery.foundation.ui.framework.widget.NodataWarnLayout;
import java.util.List;
import o.azb;
import o.chd;
import o.dgh;
import o.dgm;
import o.Logger;
import o.eph;
import o.epv;
import o.epw;
import o.CollectCheck;
import o.evg;
import o.ewm.c;
import o.ewm.h;
import o.ewm.j;
import o.ewm.n;

public abstract class BaseSubstanceDetailFragment<T extends AppListFragmentProtocol> extends AppListFragment<T> implements eph {
    protected FlowCardView ˊ = null;
    private int ॱॱ;

    protected abstract boolean ˊʻ();

    protected abstract void י();

    protected abstract List<CardBean> ٴ();

    protected abstract void ॱ(View view);

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View ˋ = super.ˋ(layoutInflater, viewGroup, bundle);
        י();
        ॱˉ();
        return ˋ;
    }

    public void ˋ(ViewGroup viewGroup, LayoutInflater layoutInflater) {
        super.ˋ(viewGroup, layoutInflater);
        ˎ(viewGroup);
    }

    private void ˎ(ViewGroup viewGroup) {
        if (viewGroup != null && this.ͺˎ != null && this.י != null && ˊʻ()) {
            this.ˊ = (FlowCardView) viewGroup.findViewById(j.ˌꞌ);
            LayoutParams layoutParams = new FrameLayout.LayoutParams(epv.ˎ(ॱˋ()), -2);
            layoutParams.gravity = 81;
            this.ˊ.setLayoutParams(layoutParams);
            this.ˊ.ˎ();
            this.ˊ.setFlowLayoutAnimation((FrameLayout) viewGroup.findViewById(j.ˍˌ));
            ॱ(this.ˊ.ॱ());
        }
    }

    public void ॱ(NodataWarnLayout nodataWarnLayout) {
        if (nodataWarnLayout != null) {
            nodataWarnLayout.setWarnImage(e.ˍ);
            nodataWarnLayout.setWarnTextOne(n.ॱˍ);
            nodataWarnLayout.setViewVisible(NodataWarnLayout.e.ˏ, 8);
            nodataWarnLayout.setViewVisible(NodataWarnLayout.e.ˎ, 8);
        }
    }

    public int ߵ() {
        return h.ˊʾ;
    }

    public int ᵎ() {
        return h.ˆ;
    }

    private void ॱˉ() {
        if (this.י != null && ˊʻ()) {
            ߺ();
        }
        ॱـ();
    }

    public void ॱ(b bVar) {
        super.ॱ(bVar);
        if (this.ˋ != null) {
            DetailResponse detailResponse = (DetailResponse) this.ˋ.ˋ;
            if (detailResponse == null) {
                return;
            }
            if (CollectCheck.isEmpty(detailResponse.ʻॱ()) || CollectCheck.isEmpty(detailResponse.ᐝॱ())) {
                detailResponse.ˏ("   ");
                detailResponse.ˋ(0);
            }
        }
    }

    protected void ߺ() {
        List ٴ = ٴ();
        if (CollectCheck.isEmpty(ٴ) || this.ˊ == null) {
            Logger.e("BaseSubstanceDetailFragment", "flowcard data is empty, need not show flow card ");
            return;
        }
        if (!this.ˊ.ˋ((CardBean) ٴ.get(0))) {
            this.ˊ = null;
            Logger.e("BaseSubstanceDetailFragment", "set flowcarddata failed, need not show flow card ");
        } else if (this.ˊ.ˊ()) {
            this.ˊ.setVisibility(0);
        } else {
            this.ˊ.setVisibility(8);
        }
    }

    private void ॱـ() {
        if (this.ॱˍ != null && this.י != null) {
            ˎ(this.ͺˏ, this.י.csSheet, this.ˋʻ, this.ॱˍ.findViewById(j.ʾˉ));
            if (epw.ˏ() && this.ᵢ != null) {
                this.ᵢ.ˎ(this.ͺˏ);
            }
        }
    }

    private void ˎ(int i, CSSStyleSheet cSSStyleSheet, String str, View view) {
        if (view != null && this.ͺˎ != null && azb.ˎ(ॱˋ())) {
            int ˎ = epv.ˎ(ॱˋ());
            int ॱ = (azb.ॱ(ॱˋ()) - ˎ) / 2;
            this.ͺˎ.setPadding(ॱ, this.ͺˎ.getPaddingTop(), ॱ, this.ͺˎ.getPaddingBottom());
            View findViewById = view.findViewById(j.ߴᐝ);
            View findViewById2 = view.findViewById(j.ǃ);
            View findViewById3 = view.findViewById(j.ᵎˊ);
            if (azb.ˎ(ॱˋ())) {
                findViewById.setVisibility(0);
                findViewById2.setVisibility(0);
                findViewById3.setVisibility(0);
                LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) findViewById.getLayoutParams();
                LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) findViewById2.getLayoutParams();
                LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) findViewById3.getLayoutParams();
                layoutParams.width = ॱ;
                layoutParams2.width = ॱ;
                layoutParams3.width = ˎ;
                findViewById.setLayoutParams(layoutParams);
                findViewById2.setLayoutParams(layoutParams2);
                findViewById3.setLayoutParams(layoutParams3);
                ॱˋ().getWindow().getDecorView().setBackgroundColor(ॱˋ().getResources().getColor(c.ˋॱ));
                this.ͺˎ.setBackgroundColor(ॱˋ().getResources().getColor(c.ॱˎ));
                findViewById.setBackgroundColor(ॱˋ().getResources().getColor(c.ˋॱ));
                findViewById2.setBackgroundColor(ॱˋ().getResources().getColor(c.ˋॱ));
                if (cSSStyleSheet != null && str != null && i == 1) {
                    CSSRule rule = new CSSSelector(str).getRule(cSSStyleSheet.getRootRule());
                    if (rule != null) {
                        rule = new CSSSelector(".body").getRule(rule);
                        if (rule != null && rule.getStyleDeclaration() != null) {
                            CSSDeclaration styleDeclaration = rule.getStyleDeclaration();
                            if (styleDeclaration != null) {
                                CSSMonoColor cSSMonoColor = (CSSMonoColor) styleDeclaration.getPropertyValue(CSSPropertyName.BACKGROUND_COLOR);
                                if (cSSMonoColor != null) {
                                    int color = cSSMonoColor.getColor();
                                    findViewById.setBackgroundColor(ˊ(color, 0.9f));
                                    findViewById2.setBackgroundColor(ˊ(color, 0.9f));
                                    this.ͺˎ.setBackgroundColor(0);
                                    ॱˋ().getWindow().getDecorView().setBackgroundColor(color);
                                    return;
                                }
                                return;
                            }
                            return;
                        }
                        return;
                    }
                    return;
                }
                return;
            }
            findViewById.setVisibility(8);
            findViewById2.setVisibility(8);
            findViewById3.setVisibility(8);
        }
    }

    private int ˊ(int i, float f) {
        if (f == 1.0f) {
            return i;
        }
        return Color.argb((int) (((float) Color.alpha(i)) * f), (int) (((float) Color.red(i)) * f), (int) (((float) Color.green(i)) * f), (int) (((float) Color.blue(i)) * f));
    }

    public void ՙ() {
        super.ՙ();
        if (this.ॱˍ != null) {
            ˎ(this.ͺˏ, this.י.csSheet, this.ˋʻ, this.ॱˍ.findViewById(j.ʾˉ));
        }
    }

    public void ˏ(String str) {
        dgh.ˋ("340201", evg.ˏ(str, this.ʼˊ, String.valueOf(this.ॱॱ)));
    }

    public void ˋᐝ() {
        super.ˋᐝ();
        if (this.ॱˍ != null && this.י != null) {
            evg.ˎ(this.ॱॱ, this.ʼˊ, this.ʾॱ);
        }
    }

    public void ˌ() {
        super.ˌ();
        this.ॱॱ = dgm.ˎ(ॱˋ());
        if (this.ॱˍ != null && this.י != null) {
            this.ʾॱ = evg.ॱ(this.ॱॱ, this.ʼˊ);
        }
    }

    public String ॱʾ() {
        if (this.ˊ == null || this.ˊ.ˏ() == null) {
            return null;
        }
        return this.ˊ.ˏ().ॱˌ();
    }

    public boolean ˏ(chd o_chd, DetailResponse detailResponse) {
        if (this.ˏ == 1) {
            ˎ(this.ॱˍ);
            ॱˉ();
        }
        return super.ˏ(o_chd, detailResponse);
    }
}
